import struct

with open("g2cSendServerListRespond.txt", "rb") as f:
    line = f.read()

#  一个byte类型相当于一个char
h, a = struct.unpack("=H130s", line)
print("包体长度:", h)
a1, a2, a3, a4 = struct.unpack("=BHi123s", a)
print("byProtocol:", a1)
print("uSize:", a2)
print("nSeverListVersion:", a3)

for i in range(3):
    a5, a6, a7, a8 = struct.unpack("IIB32s", a4[i * 41:(i + 1) * 41])
    print("dwIndex:", a5, "dwServerId:", a6, "byType:", a7, "szServerName:", a8.decode('utf-8', errors='ignore'))
# 获取你按规格截取的二进制长度
# print(struct.calcsize("=Bi80s50s"))
